package com.qf.lanzhou.blog.api.dao.Impl;

import com.qf.lanzhou.blog.api.dao.UpdateArticleDao;
import com.qf.lanzhou.blog.api.pojo.entity.Article;
import com.qf.lanzhou.blog.api.util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @Author Nerly
 * @Date 2020/12/21 16:35
 * @JDK 1.8
 * @Version 1.0
 */
public class UpdateArticleDaoImpl implements UpdateArticleDao {
    private static QueryRunner queryRunner;

    static {
        queryRunner = new QueryRunner(DruidUtil.getDataSource());
    }

    @Override
    public void updateArticle(Article article) {
        String sql = "UPDATE t_article SET article_name=?,article_contain=?,article_introduction=? WHERE article_id=?";
        Object[] params = {article.getArticleName(), article.getArticleContain(), article.getArticleIntroduction(), article.getArticleId()};
        try {
            queryRunner.update(sql, params);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
